#include <iostream>
#include <cstdio>
#include <pthread.h>
#include <unistd.h>

void *routine(void *args)
{
    while (true)
    {
        sleep(1);
        std::cout << "我是一个线程，name：" << ((char *)args) << "线程id: " << pthread_self() << std::endl;
    }
    return nullptr;
}

int main()
{
    pthread_t thd;
    int n = pthread_create(&thd, nullptr, routine, (void *)"thread-1");

    while (true)
    {
        std::cout << "我是主线程.... 线程id：" << pthread_self() << std::endl;
        sleep(1);
    }

    void *retval;
    pthread_join(thd, &retval);
    std::cout << "retval: " << (long long int)retval << std::endl;

    return 0;
}